﻿<%@ WebHandler Language="C#" Class="BDKaiJiang" %>

using System;
using System.Data;
using System.Web;
using Newtonsoft.Json;
using System.Web.Script.Serialization;
using BLL;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;

public class BDKaiJiang : IHttpHandler
{
    private string tdValue = "";
    private string cptype = "";
    public void ProcessRequest(HttpContext context)
    {
        string m = context.Request["m"];
        if (m.Equals("BDkaijiang"))
        {
            tdValue = context.Request["tdValue"];
            cptype = context.Request["cptype"];
            kaijiang(tdValue,cptype);

        }
    }

    public bool IsReusable
    {
        get { return false; }
    }


    private void kaijiang(string numqs,string cptype)
    {

        string sql = " select top 1 [LotteryType],[LotteryNo] ,[LotteryQS],[oneCount],[oneMoney],[twoCount],[twoMoney]  from [dbo].[LotteryAnnouncement] where LotteryQS=" + numqs + " and LotteryType="+cptype+"";

        DataTable QGKaijiang_Dt =   BLL.LotteryBuyDetail.GetPageListBysql(sql);
        DataTable ZNKaijiang_Dt= jiang(tdValue, cptype);
        Hashtable ht = new Hashtable();
        ht.Add("a", QGKaijiang_Dt);
        ht.Add("b", ZNKaijiang_Dt);
       
        HttpContext.Current.Response.Write(JsonConvert.SerializeObject(ht));
    }

    private DataTable jiang(string numqs,string cptype)
    {
        string sqls =@"select   isnull(sum([oneCount]),0) as [oneCounts] ,
                                                   isnull(sum([twoCount]),0) as [twoCounts] ,
                                                   isnull(sum([threeCount]),0) as [threeCounts] ,
                                                   isnull(sum([fourCount]),0) as [fourCounts] ,
                                                   isnull(sum([fiveCount]),0) as [fiveCounts] ,
                                                   isnull(sum([sixCount]),0) as [sixCounts] ,
                                                   isnull(sum([sevenCount]),0) as [sevenCounts]
                             from  LotteryAnnouncementMy  where  LotteryQS=" + numqs + " and LotteryType=" + cptype + "  group by [LotteryQS] order by [oneCounts] desc ";
        DataTable Zjs = BLL.LotteryBuyDetail.GetPageListBysql(sqls);
        return Zjs;
       
    }

}